-- SPDX-License-Identifier: GPL-3.0-or-later

local extension = Package:new("MEMEtoken", Package.CardPack)
extension.extensionName = "MEMEtoken"

extension:loadSkillSkelsByPath("./packages/internetMEME/pkg/MEMEtoken/skills")

Fk:loadTranslationTable{
  ["MEMEtoken"] = "MEME卡牌",
}


--装备↓


local progoldsheild = fk.CreateCard{
  name = "&progoldsheild",
  type = Card.TypeEquip,
  sub_type = Card.SubtypeArmor,
  attack_range = 1,
  equip_skill = "#progoldsheild_skill",
  on_install = function(self, room, player)
    if (player.general == "CaptainAmerica" or player.deputyGeneral == "CaptainAmerica") or
    (player.general == "AmericanSpy" or player.deputyGeneral == "AmericanSpy") then
      if player.phase == Player.NotActive then
        room:changeShield(player, 2)
      else
        local targets = table.filter(player.room:getOtherPlayers(player), function(p) return not p:isNude() end)
        if #targets == 0 then return false end
        local target = room:askToChoosePlayers(player, {
          targets = targets,
          min_num = 1,
          max_num = 1,
          prompt = "#progoldsheild-acquire",
          skill_name = self.name,
          cancelable = false
        })
        if #target > 0 then
          local card = room:askToChooseCard(player, {
            target = target[1],
            flag = "he",
            skill_name = "progoldsheild",
          })
          room:throwCard(card, "progoldsheild", target[1], player)
        end
      end
      
    else
      local canDiscard = table.filter(player:getCardIds("h"), function(id) return not player:prohibitDiscard(Fk:getCardById(id)) end)
      if #canDiscard then
        room:throwCard(table.random(canDiscard, 1), "progoldsheild", player, player)
      end
    end
    Armor.onInstall(self, room, player)
  end,
}
Fk:loadTranslationTable{
  ["progoldsheild"] = "振金盾牌",
  ["#progoldsheild-acquire"] = "振金盾牌：弃置一名其他角色一张牌",
  [":progoldsheild"] = "装备牌·防具<br/>"..
  "<b>防具技能</b>：锁定技，此牌的装备者为“美国队长”或“美国密探”时，其攻击范围+5。此牌进入“美国队长”或“美国密探”的装备区时，若当前为其回合外/内，其获得2点护甲/弃置一名其他角色一张牌；否则其随机弃置一张手牌。",
}
extension:addCardSpec("progoldsheild", Card.Diamond, 13 --[[{ presentcard = 1 } 赠予拍]] )


-- local dienddriver = fk.CreateCard{
--   name = "dienddriver",
--   type = Card.TypeEquip,
--   sub_type = Card.SubtypeTreasure,
--   equip_skill = "#dienddriver_skill",
--   on_install = function(self, room, player)
--     room:setPlayerMark(player, "@original_general", player.general)
--     room:changeHero(player, "DIEND", false, false, true, true)
--     Treasure.onInstall(self, room, player)
--   end,
--   on_uninstall = function(self, room, player)
--     local original = player:getMark("@original_general")
--     if original ~= "" and original ~= "0" then  -- 修改为检查非空字符串
--       room:changeHero(player, original, false, false, true, false)
--       room:setPlayerMark(player, "@original_general", 0)
--     end
--     Treasure.onUninstall(self, room, player)
--   end,
-- }
-- Fk:loadTranslationTable{
--   ["dienddriver"] = "DIEND驱动器",
--   [":dienddriver"] = "装备牌·宝物<br/>"..
--   "<b>防具技能</b>：锁定技，此牌进入装备区时，你变身为“假面骑士终骑”。离开时，你变回原武将。",
--   ["@original_general"] = "原武将",
-- }
-- extension:addCardSpec("dienddriver", Card.NoColor, 21 --[[{ presentcard = 1 } 赠予拍]] )


extension:loadCardSkels {
  progoldsheild,
  -- dienddriver,
}

return extension
